package com.justgame.project.generator.schema;

import lombok.Data;
import lombok.Getter;

import java.util.List;

@Data
@Getter
public class TableSQLCreator {
    private final String tableName;
    private final String comment;
    private final String charset;
    private List<String> indexNames;
    private List<Field> fields;

    @Data
    public static class Field{
        private String name;
        private String type;
        private String length;
        private String comment;
        private Boolean isPrimaryKey;
    }

    private TableSQLCreator(String tableName,String comment,String charset){
        this.tableName = tableName;
        this.charset = charset;
        this.comment = comment;
    }

    public TableSQLCreator indexNames(List<String> indexNames){
        this.indexNames = indexNames;
        return this;
    }

    public TableSQLCreator fields(List<Field> fields){
        this.fields = fields;
        return this;
    }

    public static TableSQLCreator builder(String tableName,String comment,String charset){
        return new TableSQLCreator(tableName,comment,charset);
    }

    @Override
    public String toString() {
        return "TableSQLCreator{" +
                "tableName='" + tableName + '\'' +
                ", comment='" + comment + '\'' +
                ", charset='" + charset + '\'' +
                ", indexNames=" + indexNames +
                ", fields=" + fields +
                '}';
    }
}
